import time

from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
from selenium.webdriver.support.select import Select
testCase = "DBshop030"
firefox = openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox,'商品管理','商品标签','普通商品标签')

# 1.点击“编辑”按钮，标签分类可改为“小米第二”，标签名称“小米机器人”，标签排序“2”。
firefox.find_element_by_xpath('//td[contains(text(),"华为手机")]//following-sibling::td[3]/a[1]').click()
s= Select(firefox.find_element_by_id('tag_group_id'))
s.select_by_visible_text('小米第二')
firefox.find_element_by_id('tag_name').clear()
firefox.find_element_by_id('tag_name').send_keys('小米机器人')
s= Select(firefox.find_element_by_id('tag_group_id'))
firefox.find_element_by_id('tag_sort').send_keys('2')

# 2.点击“保存标签信息”按钮，编辑成功。
firefox.find_element_by_xpath('//button[contains(text(),"保存标签信息")]').click()
time.sleep(5)

try:
    firefox.find_element_by_xpath('//td[contains(text(),"小米机器人")]')

    writeLog("%s 测试通过"%testCase)
except:
    writeLog("%s 测试失败"%testCase)
    getPhoto(firefox)

firefox.quit()